
<div class="container">
    <form action="<?php echo base_url('index.php/postagem/postar')  ?>" method="POST" enctype="multipart/form-data" id="formpost">
        <div class="col-sm-10">
            <fieldset>
                <legend>Poste algo...</legend>
                <div class="form-group">
                    <div>
                        <a href="#" id="lnkPic" onclick="$('#uplPic')[0].click()" >
                            <span class="glyphicon glyphicon-picture"></span></a>
                        <input type="file" name="imagem" id="uplPic" style="display: none;" accept="image/*" 
                               onchange="javascritp:
                                $('#formpost')[0].action = '<?php echo base_url('index.php/postagem/uploadImage') ?>';
                                $('#formpost')[0].submit();">
                    </div>
                     <?php if($this->session->flashdata('msgErroUpload')){ ?>
                       <div class="alert alert-danger">
                            <?php echo $this->session->flashdata('msgErroUpload'); ?>
                        </div>
                    <?php } ?>
                    <?php if($this->session->flashdata('fotoPostada')) { echo form_hidden('pstImg', $this->session->flashdata('fotoPostada')); ?>
                       <img src="<?php echo base_url('UploadImg/Posts/'.$this->session->flashdata('fotoPostada').'.jpg') ?>" alt="" class="img-rounded" height="200">
                    <?php } else{ echo form_hidden('pstImg', ''); }?>   
                        <?php if($this->session->flashdata('erroPostagem')){ ?>
                       <div class="alert alert-danger">
                            <?php echo $this->session->flashdata('erroPostagem'); ?>
                        </div>
                    <?php } ?>
                    <textarea name="postagem" class="form-control" rows="3" maxlength="255" required="" style="resize: none"></textarea>
                </div>
                <button type="submit" class="btn">Postar</button>
            </fieldset>
        </div>
    </form>
    
    <div class="col-sm-10" style="padding-top: 30px">
        <table class="table table-striped">
            <?php foreach ($postagens as $postagem) { ?>
                <tr>
                    <td>
                        <div class="media">
                            <a class="pull-left" href="#">
                                <a class="pull-left" href="<?php echo base_url('UploadImg/Perfil/' . $postagem->Foto . '.jpg') ?>">
                                <img class="media-object" alt=".." src="<?php echo base_url('UploadImg/Perfil/' . $postagem->Foto . '.jpg') ?>" style="height: 50px;">  </a>
                                </a>
                            <div class="media-body">
                                <h4 class="media-heading"><?php echo $postagem->Nome ?></h4>
                                <h5><?php echo $postagem->Texto ?></h5>
                                <?php if ($postagem->Imagem) { ?>
                                    <a class="pull-left" href="<?php echo base_url('UploadImg/Posts/' . $postagem->Imagem . '.jpg') ?>">
                                        <img class="media-object" height="300"
                                             src="<?php echo base_url('UploadImg/Posts/' . $postagem->Imagem . '.jpg') ?>" alt="...">
                                    </a>
                                <?php } ?>             
                            </div>              
                        </div>    

                    </td>
                </tr> 
            <?php } ?>
        </table>
    </div>    
</div>
